<!--{include member/header}-->
<script type="text/javascript">
	$(function(){
		$('#content .f-city').change(function(){
			var self = this;
			$(self).nextAll().remove();
			if(!$(self).val()) return;
			$.ajax({
				type: "POST",
			   	url: "{$DOMAIN_ROOT}index.php/member/getCityChildren",
				dataType:'json',
			   	data: "cityid="+$(self).val(),
			   	success: function(data){
			     if(!data.length){
				 	return;
				 }
				 var tmp = '&nbsp;<select name="city" class="f-city">';
				 for(var i in data){
				 	var city = data[i];
					tmp += '<option value="'+city.id+'">'+city.name+'</option>';
				 }
				 tmp+='</select>';
				 $(self).after($(tmp));
			   }
			});
		});
		$('#signup-user-form').submit(function(){
			$.ajax({
				type:'POST',
				url:'{$DOMAIN_ROOT}index.php/member/register',
				dataType:'html',
				data:$(this).serialize(),
				success:function(data){
					if(data=='-1'){
						wrong('email不能为空！');
					}else if(data =='-2'){
						wrong('email格式不正确！');
					}else if(data == '-3'){
						wrong('用户名不能为空！');
					}else if(data == '-4'){
						wrong('用户名不合法！');
					}else if(data == '-5'){
						wrong('密码不能为空！');
					}else if(data == '-6'){
						wrong('两次密码不一致！');
					}else if(data == '-7'){
						wrong('手机号码不能为空！');
					}else if(data == '-8'){
						wrong('手机号码不合法！');
					}else if(data == '-9'){
						wrong('所在城市没有选择！');
					}else if(data == '-10'){
						wrong('邮箱已存在！');	
					}else if(data == '-11'){
						wrong('用户名已存在！');
					}
					else if(data == '1'){
						right('注册成功！',function(){
							window.location = "/index.php/member";
						});
					}	
				}
			});
		});
	});
</script>
<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="signup">
    <div id="content" class="signup-box">
        <div class="box">
            <div class="box-top"></div>
            <div class="box-content">
                <div class="head"><h2>注册</h2><span>&nbsp;或者 <a href="{$DOMAIN_ROOT}index.php/member">登录</a></span></div>
                <div class="sect">
                    <form id="signup-user-form" method="post" action="javascript:;" class="validator">
                        <div class="field email">
                            <label for="signup-email-address">Email</label>
                            <input size="30" name="email" id="signup-email-address" class="f-input" value="" require="true" datatype="email|ajax" url="/ajax/validator.php" vname="signupemail" msg="|" type="text">
                            <span class="f-input-tip">请输入有效的Email地址</span>
                            <span class="hint">登录及找回密码用，不会公开</span>
                        </div>
                        <div class="field username">
                            <label for="signup-username">用户名</label>
                            <input size="30" name="username" id="signup-username" class="f-input" value="" datatype="limit|ajax" require="true" min="2" max="16" maxlength="16" url="/ajax/validator.php" vname="signupname" msg="|" type="text">
                            <span class="hint">4-16 个字符，一个汉字为两个字符</span>
                        </div>
                        <div class="field password">
                            <label for="signup-password">密码</label>
                            <input size="30" name="password" id="signup-password" class="f-input" require="true" datatype="require" type="password">
                            <span class="hint">最少 4 个字符</span>
                        </div>
                        <div class="field password">
                            <label for="signup-password-confirm">确认密码</label>
                            <input size="30" name="password2" id="signup-password-confirm" class="f-input" require="true" datatype="compare" compare="signup-password" type="password">
                        </div>
                        <div class="field">
                            <label for="signup-password-confirm">手机号码</label>
                            <input value="" size="30" name="mobile" id="signup-mobile" class="number" type="text"><span class="inputtip">手机号码是我们联系你的最重要的联系方式，并用于纷纷券的短信通知</span>
                        </div>
						<div class="field city">
                            <label id="enter-address-city-label" for="signup-city">所在城市</label>
							<select name="province" class="f-city">
								<option value="">==请选择==</option>
								<!--{loop $citys $index $one}-->
								<option value="{$index}">{$one}</option>
								<!--{/loop}-->
							</select>
                        </div>
						 <div class="field subscribe">
                            <input tabindex="3" value="1" name="subscribe" id="subscribe" class="f-check" checked="checked" type="checkbox">
                            <label for="subscribe">订阅每日最新团购信息</label>
                        </div>
                        <div class="act">
                            <input value="注册" name="commit" id="signup-submit" class="formbutton" type="submit">
                        </div>
                    </form>
                </div>
            </div>
            <div class="box-bottom"></div>
        </div>
    </div>
    <div id="sidebar">
        <div class="sbox">
            <div class="sbox-top"></div>
            <div class="sbox-content">
                <div class="side-tip tip" style="padding-top: 4px;">
                    <h2>已有纷纷团帐户？</h2>
                    <p>请直接<a href="{$DOMAIN_ROOT}/index.php/member">登录</a>。</p>
                </div>
            </div>
            <div class="sbox-bottom"></div>
        </div>
    </div>
</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->
<!--{include member/footer}-->